package cn.work100.modular.layuiMsn.dataControl.service.impl;

import cn.work100.core.common.page.LayuiPageFactory;
import cn.work100.core.common.page.LayuiPageInfo;
import cn.work100.modular.layuiMsn.dataControl.mapper.LayimUserFriendMapper;
import  cn.work100.modular.layuiMsn.dataControl.service.LayimUserFriendService;
import cn.stylefeng.roses.core.util.ToolUtil;
import cn.work100.modular.layuiMsn.entity.db.LayimUserFriend;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 好友关系 服务实现类
 * </p>
 *
 * @author LHX
 * @since 2019-06-05
 */
@Service
public class LayimUserFriendServiceImpl extends ServiceImpl<LayimUserFriendMapper, LayimUserFriend> implements LayimUserFriendService {

    @Override
    public void add(LayimUserFriend param){
        LayimUserFriend entity = getEntity(param);
        this.save(entity);
    }

    @Override
    public void delete(LayimUserFriend param){
        this.removeById(getKey(param));
    }

    @Override
    public void update(LayimUserFriend param){
        LayimUserFriend oldEntity = getOldEntity(param);
        LayimUserFriend newEntity = getEntity(param);
        ToolUtil.copyProperties(newEntity, oldEntity);
        this.updateById(newEntity);
    }

    private Serializable getKey(LayimUserFriend param){
        return param.getId();
    }

    private Page getPageContext() {
        return LayuiPageFactory.defaultPage();
    }

    private LayimUserFriend getOldEntity(LayimUserFriend param) {
        return this.getById(getKey(param));
    }

    private LayimUserFriend getEntity(LayimUserFriend param) {
        LayimUserFriend entity = new LayimUserFriend();
        ToolUtil.copyProperties(param, entity);
        return entity;
    }

}
